import Taro, { Component } from '@tarojs/taro'
import classnames from 'classnames'
import PropsType from 'prop-types'
import { View, Image, Text } from '@tarojs/components'
import '../styles/usercar.scss'

const itemIcon = require('../assete/icon_car.png')

export default class DUserCar extends Component {

    onHandleCar() {
        this.props.onHandleCar && this.props.onHandleCar(...arguments)
    }

    getStatus(status){
        return{
            $0:'未审核',
            $1:'审核通过',
            $2:'审核未通过'
        }[`$${status}`]
        }
       
    render() {
        const {
            className,
            list = [
                {
                    title: '六轴重型板车',
                    age: '9年',
                    name: '张三',
                    order: '粤A12345',
                    status:'待审核'
                }
            ]
        } = this.props
        return (
            <View className={classnames('b_usercar', className)}>
                {
                    list && list.map((item, i) => {
                        return <View className='b_usercar__box' onClick={this.onHandleCar.bind(this,item.id,item.status,item)}>
                            <View className='b_usercar__title' key={i} >
                              <Image src={itemIcon} className='b_usercar__image'></Image>
                              <View className='b_usercar__title_text'>{item.title}</View>
                              <View className='b_usercar__title_status'>{this.getStatus(item.status)}</View>
                            </View>
                            <View className='b_usercar__age'>车龄：{item.age}</View>
                            <View className='b_usercar__footer'>
                                <Text className='b_usercar__footer_name'>司机姓名：{item.name}</Text>
                                <Text className='b_usercar__footer_order'>{item.order}</Text>
                            </View>
                        </View>
                    })
                }
            </View>
        )
    }
}

DUserCar.defaultProps = {
    className: '',
    onHandleCar: () => { }
}

DUserCar.PropsType = {
    className: PropsType.oneOfType[PropsType.string, PropsType.object],
    onHandleCar: PropsType.func
}